//1.导入vue 和 vuerouter 的包
import Article from '@/view/Article.vue'
import Collect from '@/view/Collect.vue'
import Detail from '@/view/Detail.vue'
import Home from '@/view/home.vue'
import Like from '@/view/Like.vue'
import Login from '@/view/login.vue'
import Register from '@/view/register.vue'
import User from '@/view/User.vue'
import Vue from 'vue'
import VueRouter from 'vue-router'

//2.调用vue.use() 函数，把 VueRouter 安装为 Vue 的插件
//vue.use()函数的作用，就是来安装插件的
Vue.use(VueRouter)
 
//3.创建路由的实例对象
const router = new VueRouter({
    routes:[
        {path: '/' , redirect:'/login'},
        { path: '/login' , component:Login},
        { path: '/register' , component:Register},
        { path: '/home' , component:Home,
            children: [
                { path: '/article', component: Article },
                { path: '/like', component: Like },
                { path: '/collect', component: Collect },
                { path: '/user', component: User }
              ]
        
        },
        { path: '/article/:id', component: Detail },
        ]  
}
)
//4.向外共享路由的实例对象
export default router